<?	
    session_start();
    include('conn.php');
    include('protect.php');
	include('gettopmenu.php');
   	error_reporting(0);

	$dt=date("d-m-Y");	    
	$msg='';    	
?>
<!doctype html>
<html lang="en">
<head>	
	<link rel="stylesheet" type="text/css" href="transaction2.css"/>
	<link href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.1.0/chosen.css" rel="stylesheet"/> 
	<link href="bootstrap.min.css" rel="stylesheet"/> 	
	<!-- <link href="select2.css" rel="stylesheet"/>
	     <script src="select2.js"></script>
	<link href="chosen.css" rel="stylesheet"/> -->
	<script type="text/javascript" src="transaction2.js"></script>
	<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js"></script>
        <script type="text/javascript" src="chosen.jquery.js"></script>	
   
	<script>
	
	$(function() 
	{		
	$(".chosen-select").chosen();
//	$(".chosen-select").select2();
    $("#datepicker3").datepicker({ dateFormat: "dd-mm-yy" ,minDate: -2}).val();
    $("#paydate").datepicker({ dateFormat: "dd-mm-yy" }).val();			   
    $("#bdt").datepicker({ dateFormat: "dd-mm-yy" }).val();			   
    $("#rdt").datepicker({ dateFormat: "dd-mm-yy" }).val();			   
    $("#tdt").datepicker({ dateFormat: "dd-mm-yy" }).val();		
	});
	
	</script>
	  
</head>

<body ng-controller="cont">
<label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Transaction / Add Transaction </label><br/> 	
	<div align="center" class="mtbl">
			<FORM METHOD="post" name="frmtran" novalidate>			
			<table>							
				<tr>
					<th colspan="3" align="left" height="40"><u>TRANSACTION </u> &nbsp;&nbsp;&nbsp;				
					<input type="radio"  value="pay" ng-model="type" ng-change="showchild()" ng-disabled="childshow">Pay &nbsp;&nbsp;&nbsp;
					<input type="radio"  value="rcv"  ng-model="type" ng-change="showchild()" ng-disabled="childshow">Receive 
					</th>				
					<td ng-show="custid!=0"><i><div id="ct"></div></i></td>
					<td colspan="5" ng-show="(type=='pay' && nature=='1')" ></td>			
					<th colspan="3" align="left" ng-show="childshow">PAX Entry <!--[Admin Charges: {{oac}}]--></th>
				</tr>
				<tr>
					<td colspan="3"><div id="msg" style="color:red;"><?=$smsg?></div></td>							
					<td ng-show="(type=='pay' && nature=='1')" colspan="3"></td>
					<td ng-show="(type=='pay' && nature=='1')" colspan="3"></td>			
					<td colspan="3">
						<div ng-show="childshow" align="left" style="color:red;">Number of passenger details entered are {{count}}</div>
					</td>							
				</tr>
				
				<tr>
					<td width="149"><label>Date</label></td>
					<td width="9"><label >:</label></td>
					<td width="200"><label><input type="text" class="input-medium" value="<?=$dt?>" name="datepicker3" id="datepicker3" ng-disabled="childshow" my-blur="datechk();"/></label></td>					
					
					<td ng-show="(type=='pay' && nature=='1')" colspan="3"></td>
					<td ng-show=" (type=='pay' && nature=='1')" colspan="3"></td>					
					
					<td width="140" ng-show="childshow"><label><div id="at-bdt1" ng-show="childshow">*Booking date</div></label></td>
					<td  width="9" ng-show="childshow"><label><div id="at-bdt2">:</div></label></td>
					<td  width="200" ng-show="childshow">
						<div id="at-bdt3" ><input type="text" class="input-medium" id="bdt" /> </div>
					</td>
				</tr>
				<tr>										
					<td ><label >*Nature Of Business</label></td> 					
					<td ><label >:</label></td>
					<td>
						<select class="chosen-select" name="bid" id="bid" ng-model="nature" ng-disabled="childshow">
						<option value="0">--</option>
						<?
							$sqlb="select * from businessmast where status=0 order by bdesc";
							$resb=mysql_query($sqlb);
							while($rowb=mysql_fetch_assoc($resb))
							{
								$val=$rowb['bid'];
								if($val == '12')
									continue;
						?>
							<option value="<?=$val?>"><?=$rowb['bdesc']?></option>
						<?	}  ?>	
						</select>						
					</td>			
						
					<td ng-show="(type=='pay' && nature=='1')" colspan="3"></td>
					<td ng-show="(type=='pay' && nature=='1')" colspan="3"></td>
										
					<td><label><div ng-show="childshow">*Passenger name</div></label></td> 
					<td><label><div ng-show="childshow">:</div></label></td>
					<td><div ng-show="childshow"><input type="text" class="input-medium" ng-model="pax"  /></div></td>
					
				</tr>
				<tr>
					<td ><label >*Client Name</label></td>
					<td ><label >:</label></td>
					<td  height="60">
						<p>
						  <select class="chosen-select" name="custid" id="custid" class="input-medium" ng-change="chgd();" ng-model="custid"  ng-disabled="childshow">
						  <option value="0">--</option>
						    <?
							$sqlct="select * from customermast where status=0 order by custdesc";
							$resct=mysql_query($sqlct);
							while($rowct=mysql_fetch_assoc($resct))
							{
							if($rowct['custtype']=='AGENT')
								$cid='d'.$rowct['custid'];
							if($rowct['custtype']=='CUSTOMER')
								$cid='c'.$rowct['custid'];
							if($rowct['custtype']=='DISTRIBUTOR')
								$cid='i'.$rowct['custid'];
                            if($rowct['custtype']=='CORPORATE')
    							$cid='r'.$rowct['custid'];
                            if($rowct['custtype']=='VENDOR')
        						$cid='v'.$rowct['custid'];							
							?>
						    <option value="<?=$cid?>">
					        <?=$rowct['custdesc']?>
					        </option>
					        <?							
							}
						?>	
					      </select>						 
					  </p>	</td>	  
					
					<td ng-show="(type=='pay' && nature=='1')" colspan="3"></td>
					<td ng-show="(type=='pay' && nature=='1')" colspan="3"></td>
					
					<td><div ng-show="childshow"><label>Ticket Number</label></div></td>
					<td><div ng-show="childshow"><label>:</label></div></td>
					<td><div ng-show="childshow"><input type="text" class="input-medium" ng-model="tno"  /></div></td>
										
				</tr>
				<!--<tr>
					<td width="99" ><label >Sub Category</label></td>
					<td width="5" ><label >:</label></td>
					<td width="200"  >
						<select  name="catid" id="catid" class="input-medium">
							<? /*
								$sqlc="select * from categorymast where status=0 order by catdesc";
								$resc=mysql_query($sqlc);
								while($rowc=mysql_fetch_assoc($resc))
								{   ?>
								<option value="<?=$rowc['catid']?>"><?=$rowc['catdesc']?></option>
							<?	}*/	?>	
						</select>				  
					</td>
					<td></td>
					<td></td>
					<td></td>
				</tr> -->
				<tr>
					<td>
					<label>
						<div ng-show="type == 'pay'">Dr. Amount</div>
						<div ng-show="type == 'rcv'">Cr. Amount</div>
					</label>
					</td>					
					<td><label>:</label>	</td>										
					<td>
						<div ng-show="type=='pay'"> <input name="dramount" type="number" id="dramount"  placeholder="0" ng-model="Dr_Amount" class="input-medium" ng-disabled="childshow"/> 	</div>
						<div ng-show="type=='rcv'"> <input name="cramount" type="number"  id="cramount" placeholder="0" ng-model="Cr_Amount" class="input-medium" ng-disabled="childshow"/> 	</div>
					</td>
					
					<td ng-show="(type=='pay' && nature=='1')" colspan="3"></td>
					<td ng-show="(type=='pay' && nature=='1')" colspan="3"></td>
					
					<td><label><div ng-show="childshow">ID number 2</div></label></td>
					<td><label ><div ng-show="childshow">:</div></label></td>
					<td ><div ng-show="childshow"><input type="text" class="input-medium"  ng-model="pnr"  /></div></td>
					
				</tr>
              <!--  <tr>
					<td ><label >Sub-Agent Name </label></td>
					<td ><label >:</label></td>
					<td >
						<select  name="sid" id="sid" class="input-medium" >
						<? /*
							$sqlcts="select * from subdealermast where status=0 order by subname";
							$rescts=mysql_query($sqlcts);
							while($rowcts=mysql_fetch_assoc($rescts))
							{
						?>
							<option value="<?=$rowcts['subid']?>"><?=$rowcts['subname']?></option>
						<?
							}
						*/ ?>	
						</select>					
					</td>
					
					<td></td>  <td></td>	<td></td>									
				</tr>-->
                    <tr>
					<td><label>Remarks</label></td>
					<td><label>:</label></td>
					<td><textarea name="remarks" rows="2" class="input-medium" ng-model="remarks"  ng-disabled="childshow"></textarea></td>		
					
					<td ng-show="(type=='pay' && nature=='1')" colspan="3"></td>
					<td ng-show="(type=='pay' && nature=='1')" colspan="3"></td>
					
					<td><label><div ng-show="childshow">*Travel Date</div></label></td>
					<td><label><div ng-show="childshow">:</div></label></td>
					<td><div ng-show="childshow"><input type="text" class="input-medium" ng-model="tdt" id="tdt"/></div></td>			
				</tr>
                <tr>
					<td >
						<label ng-show="type=='pay'">
						<input ng-show="nature=='1' || nature=='9'" type="checkbox" ng-model="chk1" ng-disabled="childshow || venid1=='0'"/>
						<span ng-show="nature=='1'">*</span>Supplier Name 1</label>
						<label ng-show="type== 'rcv'">*Pay Date</label>
					</td>
					<td ><label>:</label></td>
					<td  height="40"> 
					<div ng-show="type=='pay'">
						<select  name="venid" id="venid" ng-model="venid1" class="chosen-select" ng-disabled="childshow" >
						<option value="0">--</option>
						<?
							$sqlb="select * from customermast where status=0 order by custdesc";
							$resb=mysql_query($sqlb);
							while($rowb=mysql_fetch_assoc($resb))
							{
						?>
							<option value="<?=$rowb['custid']?>"><?=$rowb['custdesc']?></option>
						<?
							}
						?>	
						</select>
						</div>		
						<!--<input type="date" ng-show="type== 'rcv'" id="paydate"  value="<?=$dt1?>" class="input-medium" ng-model="paydateval">  -->
						<input type="text" ng-show="type== 'rcv'" id="paydate" value="<?=$dt?>" class="input-medium" ng-model="paydateval" ng-disabled="childshow"> 				
										
					</td>
					
					<td width="120" ng-show="(nature == '1' || venid1 != '0') && type=='pay'">
						<label ><div id="netfield1" >Net Buy Rate 1 </div></label></td>
					<td ng-show="(nature == '1' || venid1 != '0') && type=='pay'">
						<label ><div id="netfield2" >:</div></label></td>
					<td width="100" ng-show="(nature == '1' || venid1 != '0') && type=='pay'" >
						<div id="netfield3">
							<input ng-model="nr1" type="number" class="input-small" id="netrate" placeholder="0" ng-disabled="childshow"/>	
					</div></td>
					
					<td ng-show="(nature == '1' && type=='pay')"><label >PNR number 1</label></td>
    				<td  ng-show="(nature == '1' && type=='pay')"><label>:</label></td>
					<td  ng-show="(nature == '1' && type=='pay')"><input type="text" class="input-small" ng-model="pnr_parent1" ng-disabled="childshow"/></td>
										
					<td><label><div  ng-show="childshow">Return Date</div></label></td>				
					<td><label><div  ng-show="childshow">:</div></label></td>				
					<td><div ng-show="childshow"><input type="text" class="input-medium" id="rdt" ng-model="rdt" /></div></td>					  				
				</tr>
				
				<tr>
					<td>
						<label ng-show="type== 'rcv'">*Payment Mode</label>
						<label ng-show="type=='pay'">
							<input ng-show="nature=='1' || nature=='9'" type="checkbox" ng-model="chk2" ng-disabled="childshow || venid2=='0'"/>
							Supplier Name 2
						</label>
					</td>
					<td><label>:</label></td>
					<td height="40">
						<div ng-show="type=='pay'">
							<select  ng-model="venid2" class="chosen-select"  ng-disabled="childshow" >
							<option value="0">--</option>
							<?
								$sqlb="select * from customermast where status=0 order by custdesc";
								$resb=mysql_query($sqlb);
								while($rowb=mysql_fetch_assoc($resb))
								{
							?>
								<option value="<?=$rowb['custid']?>"><?=$rowb['custdesc']?></option>
							<?
								}
							?>	
							</select>
						</div>		
						<select ng-model="payidval" ng-show="type== 'rcv'" ng-disabled="childshow"> 
                      <?
							$sqlcp="select * from paymentmast where status=0 order by pdesc";
							$rescp=mysql_query($sqlcp);
							while($rowcp=mysql_fetch_assoc($rescp))
							{							
								$val=$rowcp['payid'];
								$desc=$rowcp['pdesc'];
								if($val=='8')
								{
									$val='';
									$desc='--';
								}									
						?>
                      <option value="<?=$val?>"> <?=$desc?> </option>
                      <?  }  ?>
                    </select> 
					</td> 
					
					<td ng-show="type=='pay'"><label ng-show="venid2 != '0' "><div  >Net Buy Rate 2</div></label></td>
					<td ng-show="type=='pay'"><label ng-show="venid2 != '0' "><div >:</div></label></td>
					<td ng-show="type=='pay'"><div id="netfield3" ng-show="venid2 != '0' ">
					<input  ng-model="nr2" type="number"  class="input-small"  placeholder="0" ng-disabled="childshow" />	
					</div></td>
					
					<td ng-show="type=='pay' && nature=='1'"><label ng-show="venid2 != '0'">PNR number 2</label></td>
    				<td ng-show="type=='pay' && nature=='1'"><label ng-show="venid2 != '0'">:</label></td>
					<td ng-show="type=='pay' && nature=='1'">
						<input type="text" ng-show="venid2 != '0'" class="input-small" ng-model="pnr_parent2" ng-disabled="childshow"/>
					</td>
					
					
					<td><label><div ng-show="childshow">*Sector</div></label></td>
					<td><label><div ng-show="childshow">:</div></label></td>
					<td><div id="at-sec3"  ng-show="childshow"><input type="text" class="input-medium" ng-model="sec"  /></div></td>  
				</tr>
				<tr>
					<td>
						<label ><div id="bankfield1" ng-show="type== 'rcv'">Bank name</div></label>
						<label ng-show="type=='pay'">
							<input ng-show="nature=='1' || nature=='9'" type="checkbox" ng-model="chk3" ng-disabled="childshow || venid3=='0'"/>
							Supplier Name 3
						</label>
					</td>
					<td><label>:</label></td>
					<td height="40">
						<div id="bankfield3" ng-show="type== 'rcv'">
						<select  name="bankid"  id="bankid"  ng-model="bankval" ng-disabled="childshow"> 
						<?
							$sqlck="select * from bankmast where status=0 order by bankname";
							$resck=mysql_query($sqlck);
							while($rowck=mysql_fetch_assoc($resck))
							{
								$val=$rowck['bankid'];
								$desc=$rowck['bankname'];
								if($val == '1')
								{
									$val='';
									$desc='--';
								}								
						?>
							<option value="<?=$val?>"><?=$desc?></option>
						<?	}  ?>
						</select> 
					</div>
						<div ng-show="type=='pay'">
							<select ng-model="venid3" class="chosen-select" ng-disabled="childshow"  >
							<option value="0">--</option>
							<?
								$sqlb="select * from customermast where status=0 order by custdesc";
								$resb=mysql_query($sqlb);
								while($rowb=mysql_fetch_assoc($resb))
								{
							?>
								<option value="<?=$rowb['custid']?>"><?=$rowb['custdesc']?></option>
							<?
								}
							?>	
							</select>
						</div>
					</td>
					
					<td ng-show="type=='pay'"><label ng-show="venid3 != '0'"><div >Net Buy Rate 3</div></label></td>
					<td ng-show="type=='pay'"><label ng-show="venid3 != '0'"><div >:</div></label></td>
					<td ng-show="type=='pay'"><div ng-show="venid3 != '0'">
					<input  ng-model="nr3" type="number"  class="input-small"  placeholder="0" ng-disabled="childshow" />	
					</div></td>
					
										
					<td ng-show="type=='pay' && nature=='1'"><label ng-show="venid3 != '0'">PNR number 3</label></td>
    				<td ng-show="type=='pay' && nature=='1'"><label ng-show="venid3 != '0'">:</label></td>
					<td ng-show="type=='pay' && nature=='1'"><input ng-show="venid3 != '0'" type="text" class="input-small" ng-model="pnr_parent3" ng-disabled="childshow"/></td>
					
					<td><label><div id="at-basic1" ng-show="childshow">Basic charges</div></label></td>
					<td><label><div id="at-basic2" ng-show="childshow">:</div></label></td>
					<td><div id="at-basic3" ng-show="childshow"><input type="number" value="0" class="input-medium" ng-model="bc" ng-change="calamt()"  /></div></td>										
					
				</tr>
				<tr>
					<td width="100" ng-show="type=='pay' && childshow"><label ng-show="venid1!='0'">Admin 1 charge</label></td>
    				<td ng-show="type=='pay' && childshow"><label ng-show="venid1!='0'">:</label></td>
					<td width="100" ng-show="type=='pay' && childshow"><label ng-show="venid1!='0'">{{oac[0]}}</label></td>
					
					<td ng-show="type=='pay' && childshow"><label ng-show="venid2!='0'" >Admin 2 charge</label></td>
    				<td ng-show="type=='pay' && childshow"><label ng-show="venid2!='0'" >:</label></td>
					<td ng-show="type=='pay' && childshow"><label ng-show="venid2!='0'" >{{oac[1]}}</label></td>
					
					<td ng-show="type=='pay' && childshow"><label ng-show="venid3!='0'">Admin 3 charge</label></td>
    				<td ng-show="type=='pay' && childshow"><label  ng-show="venid3!='0'">:</label></td>
					<td ng-show="type=='pay' && childshow"><label  ng-show="venid3!='0'">{{oac[2]}}</label></td>
					
					<td ng-show="type== 'rcv'"><label><div id="branchfield1" >Branch name</div></label></td>
					<td ng-show="type== 'rcv'"><label ><div>:</div></label></td>
					<td ng-show="type== 'rcv'"><div id="branchfield3" >
					<input type="text" class="input-medium" id="branch" ng-disabled="childshow"/></div></td>	
			
					<td><label><div id="at-admin1" ng-show="childshow">Admin charges</div></label></td>
					<td><label><div id="at-admin2" ng-show="childshow">:</div></label></td>
					<td><div id="at-admin3" ng-show="childshow"><input type="number" class="input-medium" ng-model="ac"  ng-change="calamt()" value="0"  /></div></td> 												
				</tr>			
				<tr>					
					<td ><label ng-show="(nature == '15' && type=='rcv')">PNR number 1</label></td>
    				<td><label ng-show="(nature == '15' && type=='rcv')">:</label></td>
					<td ><input type="text" class="input-medium" ng-model="pnr_parent1" ng-disabled="childshow" ng-show="(nature == '15' && type=='rcv')"/></td>
										
					<td ng-show=" (type=='pay' && nature=='1')" colspan="3"></td>
					<td ng-show=" (type=='pay' && nature=='1')" colspan="3"></td>					
					
					<td><label><div id="at-tax1" ng-show="childshow">Taxes</div></label></td>
					<td><label><div id="at-tax2" ng-show="childshow">:</div></label></td>
					<td><div id="at-tax3" ng-show="childshow"><input type="number" class="input-medium" ng-model="tax_amt"   ng-change="calamt()" value="0"/></div></td>
					
				</tr>
				<tr>
					<td colspan="3" height="30">
					<div ng-show="type=='pay' && nature=='1'"><i>
						<!--Create Reverse Credit Note entry-->
						Check supplier boxes to create Reverse Credit Note</i></div>
					</td>		
					
					<!--<td>
					<div ng-show="type=='pay' && nature=='1'"><input type="checkbox" ng-model="chk" ng-show="type=='pay' && nature=='1'" ng-disabled="childshow"/></div>
					</td>					
					<td></td>					
					<td></td>-->
					<td ng-show="(type=='pay' && nature=='1')" colspan="3"></td>			
					<td ng-show="(type=='pay' && nature=='1')" colspan="3"></td>			
					
					<td><label><div id="at-amt1" ng-show="childshow">Amount</div></label></td>
					<td><label><div id="at-amt2" ng-show="childshow">:</div></label></td>
					<td><div id="at-amt3"  ng-show="childshow"><input type="number" class="input-medium" ng-model="amt"  value="0"/></div></td>
					
				</tr>
				
				<tr>
					<td align="center" colspan="2">
						<button id="save" ng-click="fn()" class="btn btn-success">
							Save Record<span ng-show="sms"> and send sms</span>
						</button>						
					</td>
					<td align="center" ng-show="childshow">
						<input type="button" ng-click="adnew()" value="Add new transaction" class="btn"/>					
					</td>
					<td colspan="3" ng-show="(type=='pay' && nature=='1')"></td>
					<td colspan="3" ng-show="(type=='pay' && nature=='1')"></td>
					
					<td align="center" colspan="3">
						<div id="at-btn" ng-click="fn2()" ng-show="childshow">
						<input type="submit" name="addtt" value="Attach entry" class="btn"  /> </div>				
					</td>
				</tr>
				<tr>
					<td colspan="5" ng-show="type=='rcv'">
						<input type="checkbox" ng-model="sms"/> Check this box to send SMS
					</td>
				</tr>
				<!--<tr ng-show="type=='pay'" ng-if="nature===1">
						<td colspan="7" ng-include src="'paxdetails.html'"></td>
        		</tr>-->
			</table>
			</FORM>		<br>		
			<div id="tbl2" style="width:75%"  ng-show="childshow">
				<table class="table">
					<tr>
						<td><label>Ticket Number</label></td>
						<td><label>ID Number2</label></td>
						<td><label>Passenger Name</label></td>
						<td><label>Booking Date</label></td>
						<td><label>Travel Date</label></td>
						<td><label>Return Date</label></td>
						<td><label>Sector</label></td>
						<td><label>Basic Charges</label></td>
						<td><label>Admin charges</label></td>
						<td><label>Tax</label></td>
						<td><label>Amount</label></td>
					</tr>
					<tr ng-repeat="x in datamast">
						<td>{{x.tno}}</td>
						<td>{{x.pnr}}</td>
						<td>{{x.paxname}}</td>
						<td>{{x.bdt}}</td>
						<td>{{x.tdt}}</td>
						<td>{{x.rdt}}</td>
						<td>{{x.sec}}</td>
						<td>{{x.bc}}</td>
						<td>{{x.ac}}</td>
						<td>{{x.tax}}</td>
						<td>{{x.amt}}</td>
					</tr>
				</table>
			</div>
	</div>
	<script>
	</script>
</body>
</html>
